/*
 * @lc app=leetcode.cn id=680 lang=javascript
 *
 * [680] 验证回文字符串 Ⅱ
 */

// @lc code=start
/**
 * @param {string} s
 * @return {boolean}
 */
var validPalindrome = function(s) {
    const test = function(str) {
        let l = 0, r = str.length - 1
        while (l < r && str[l] == str[r]) {
            l++
            r--
        }
        return l >= r
    }
    
    let i = 0, j = s.length - 1
    while (i < j) {
        if (s[i] != s[j]) {
            return test(s.slice(i, j)) || test(s.slice(i+1,j+1))
        }
        i++
        j--
    }
    return true
};
// @lc code=end

// validPalindrome("deeee")